package com.csist.service.po.basicInfoModule.impl;

import com.csist.mapper.po.basicInfoModule.EducationBackgroundMapper;
import com.csist.pojo.po.basicInfoModule.EducationBackground;
import com.csist.service.po.basicInfoModule.EducationBackgroundService;
import com.csist.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName EducationBackgroundServiceImpl
 * @Description 【自行描述】
 * @Author cn
 * @Date 2024/6/27 12:25
 * @Version 1.0
 */
public class EducationBackgroundServiceImpl implements EducationBackgroundService {

    private SqlSession sqlSession;
    private EducationBackgroundMapper educationBackgroundMapper;

    public EducationBackgroundServiceImpl() {
        sqlSession = SqlSessionUtil.openSession();
        educationBackgroundMapper = sqlSession.getMapper(EducationBackgroundMapper.class);
    }

    @Override
    public List<EducationBackground> findAll() {
        List<EducationBackground> list = educationBackgroundMapper.findAll();
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public EducationBackground getEducationBackgroundById(int id) {
        EducationBackground educationBackgroundById = educationBackgroundMapper.getEducationBackgroundById(id);
        if (educationBackgroundById != null) {
            return educationBackgroundById;
        }
        return null;
    }

    @Override
    public List<EducationBackground> findEducationBackgroundFuzzy(EducationBackground educationBackground) {
        List<EducationBackground> list = educationBackgroundMapper.findEducationBackgroundFuzzy(educationBackground);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public List<EducationBackground> findEducationBackground(EducationBackground educationBackground) {
        List<EducationBackground> list = educationBackgroundMapper.findEducationBackground(educationBackground);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public int addEducationBackground(EducationBackground educationBackground) {
        int i = educationBackgroundMapper.addEducationBackground(educationBackground);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateEducationBackground(EducationBackground educationBackground) {
        int i = educationBackgroundMapper.updateEducationBackground(educationBackground);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateEducationBackgroundByState(int ebId) {
        int i = educationBackgroundMapper.updateEducationBackgroundByState(ebId);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int deleteEducationBackground(int ebId) {
        return 0;
    }
}
